﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace WordInSequences
{
    class Program
    {
        static void Main(string[] args)
        {

            //Write a program that extracts all sentences from given text that contain given word. You can consider that a each sentence ends by ".", "?" or "!". To split the sentences use regular expressions. 
            Regex regex = new Regex(@"[0-9]+");
            String text =
              "Keywords are predefined reserved identifiers that have special meanings to the compiler. They cannot be used as identifiers in your program unless they include @ as a prefix. For example, @if is a legal identifier but if is not because it is a keyword. C# provides a large set of operators, which are symbols that specify which operations to perform in an expression. C# predefines the usual arithmetic and logical operators, as well as a variety of others. In addition, many operators can be overloaded by the user, thus changing their meaning when applied to a user-defined type. Learn about C#'s conditional compilation directives.The C# tutorials provide an overview of the basics of the language and identify important language features. Each tutorial includes one or more sample programs. The tutorials discuss the sample code plus provide additional background information. They also link to the corresponding sample abstract topics, where you can download and run the sample programs. ";
            string splitPattern = @"[.|!|?]";
            string word = "as";
            string[] sentences = Regex.Split(text, splitPattern);
            foreach (var sentence in sentences)
            {
                if (sentence != "")
                {
                    string[] words = sentence.Split(' ',',','@','(',')');
                    foreach (var w in words)
                    {
                        if (w == word)
                        {
                            Console.WriteLine(sentence);
                            break;
                        }
                    }

                }
            }
        }
    }
}
